package bean;

import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.LayoutManager;
import java.awt.Panel;
import java.awt.Window;
import java.util.ArrayList;
import java.util.List;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JWindow;
import servbean.MyBounds;
import servbean.Table;


public class FrameSetBean {
	private List<Component> component;
	private Table table;
	private MyBounds myBounds;
	public boolean init(){
		/**
		 * INIT tableBean
		 */

		String[] rowHeight = {"60%","0","30"};
		String[] columnWidth = {"100","0","100"};
		
		List<int[]> whereList = new ArrayList<int[]>();
		int[] where1 = {0,0,3,1};
		int[] where2 = {0,1,2,1};
		int[] where3 = {0,2,2,1};
		whereList.add(where1);
		whereList.add(where2);
		whereList.add(where3);
		
		this.table = new Table();
		boolean tableFlag = this.table.setModel(rowHeight,columnWidth,whereList);
		if(!tableFlag){
			return false;
		}
		
		/**
		 * INIT windows
		 */
		this.component = new ArrayList<Component>();
		JPanel j1=new JPanel();
		
//		j1.setLayout(new GridLayout(2,1));
//		j1.getContentPane().setBackground(Color.BLUE);
//		JPanel p = new JPanel();
//		p.setBackground(Color.blue);
//		JPanel p1 = new JPanel();
//		p1.setBackground(Color.orange);
//		j1.getContentPane().add(p);
//		j1.getContentPane().add(p1);
//		j1.getContentPane().setBackground(Color.red);
		
		Icon i1 = new ImageIcon("temp/1.png");
		JLabel l1 = new JLabel();
		l1.setIcon(i1);
		j1.add(l1);
//j1.add(Component c, index)
		
		JPanel j2=new JPanel();
//		j2.getContentPane().setBackground(Color.red);
		Icon i2 = new ImageIcon("temp/2.png");
		JLabel l2 = new JLabel();
		l2.setIcon(i2);
		j2.add(l2);
		
		JPanel j3=new JPanel();
		
		
		Icon i3 = new ImageIcon("temp/3.png");
		JLabel l3 = new JLabel();
		l3.setIcon(i3);
		j3.add(l3);
		
		this.component.add(j1);
		this.component.add(j2);
		this.component.add(j3);
		
		/**
		 * INIT myBounds
		 */
		this.myBounds = new MyBounds(200,100,300,600);
		return true;
	}

	public boolean initEdge(){
		/**
		 * INIT tableBean
		 */

		String[] rowHeight = {"1","3","0","3","1"};
		String[] columnWidth = {"1","3","0","3","1"};
		
		List<int[]> whereList = new ArrayList<int[]>();
		int[] where1 = {2,0,1,1};
		int[] where2 = {4,2,1,1};
		int[] where3 = {2,4,1,1};
		int[] where4 = {0,2,1,1};
		
		int[] where5 = {1,1,1,1};
		int[] where6 = {3,1,1,1};
		int[] where7 = {3,3,1,1};
		int[] where8 = {1,3,1,1};
		
		whereList.add(where1);
		whereList.add(where2);
		whereList.add(where3);
		whereList.add(where4);
		whereList.add(where5);
		whereList.add(where6);
		whereList.add(where7);
		whereList.add(where8);
		
		this.table = new Table();
		boolean tableFlag = this.table.setModel(rowHeight,columnWidth,whereList);
		if(!tableFlag){
			return false;
		}
		
		/**
		 * INIT windows
		 */
		
		this.component = new ArrayList<Component>();
		JPanel j1=new JPanel();
		j1.setBackground(Color.black);
	
		JPanel j2=new JPanel();
		j2.setBackground(Color.black);
		
		JPanel j3=new JPanel();
		j3.setBackground(Color.black);
		
		JPanel j4=new JPanel();
		j4.setBackground(Color.black);

		JLabel j5 = new JLabel(){
			@Override
			public void paint(Graphics g) {
				super.paint(g);
				Graphics2D g2d=(Graphics2D)g;

				g2d.drawLine(0, 2, 2, 0);
			}
		};
		
		JLabel j6 = new JLabel(){
			@Override
			public void paint(Graphics g) {
				super.paint(g);
				Graphics2D g2d=(Graphics2D)g;

				g2d.drawLine(0, 0, 2, 2);
			}
		};
		
		JLabel j7 = new JLabel(){
			@Override
			public void paint(Graphics g) {
				super.paint(g);
				Graphics2D g2d=(Graphics2D)g;

				g2d.drawLine(0, 2, 2, 0);
			}
		};
		
		JLabel j8 = new JLabel(){
			@Override
			public void paint(Graphics g) {
				super.paint(g);
				Graphics2D g2d=(Graphics2D)g;

				g2d.drawLine(0, 0, 2, 2);
			}
		};
		
		this.component.add(j1);
		this.component.add(j2);
		this.component.add(j3);
		this.component.add(j4);
		this.component.add(j5);
		this.component.add(j6);
		this.component.add(j7);
		this.component.add(j8);
		/**
		 * INIT myBounds
		 */
		this.myBounds = new MyBounds();
		return true;
	}
	
	public boolean initAidEdge(){
		/**
		 * INIT tableBean
		 */
		
		String[] rowHeight = {"1","2","0","2","1"};
		String[] columnWidth = {"1","2","0","2","1"};
		
		List<int[]> whereList = new ArrayList<int[]>();
		int[] where1 = {2,0,1,1};
		int[] where2 = {5,2,1,1};
		int[] where3 = {2,5,1,1};
		int[] where4 = {0,2,1,1};
		
//		String[] rowHeight = {"2","0","2"};
//		String[] columnWidth = {"2","0","2"};
//		
//		List<int[]> whereList = new ArrayList<int[]>();
//		int[] where1 = {0,0,3,1};
//		int[] where2 = {2,1,1,1};
//		int[] where3 = {0,2,3,1};
//		int[] where4 = {0,1,1,1};
		
		whereList.add(where1);
		whereList.add(where2);
		whereList.add(where3);
		whereList.add(where4);
		
		this.table = new Table();
		boolean tableFlag = this.table.setModel(rowHeight,columnWidth,whereList);
		if(!tableFlag){
			return false;
		}
		
		/**
		 * INIT windows
		 */
		this.component = new ArrayList<Component>();
		JPanel j1=new JPanel();
		j1.setBackground(Color.red);

		JPanel j2=new JPanel();
		j2.setBackground(Color.red);
		
		JPanel j3=new JPanel();
		j3.setBackground(Color.red);
		
		JPanel j4=new JPanel();
		j4.setBackground(Color.red);
		
		this.component.add(j1);
		this.component.add(j2);
		this.component.add(j3);
		this.component.add(j4);
		
		/**
		 * INIT myBounds
		 */
		this.myBounds = new MyBounds();;
		return true;
	}

	public Table getTable() {
		return table;
	}
	public void setTable(Table table) {
		this.table = table;
	}
	public MyBounds getMyBounds() {
		return myBounds;
	}
	public void setMyBounds(MyBounds myBounds) {
		this.myBounds = myBounds;
	}

	public List<Component> getComponent() {
		return component;
	}

	public void setComponent(List<Component> component) {
		this.component = component;
	}
	
}
